package cn.itcast.feign.fallback;

import cn.itcast.feign.clients.UserClient;
import cn.itcast.feign.pojo.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * ClassName: UserClientFallbackFactory
 * Package: cn.itcast.feign.fallback
 * Description:
 *
 * @Author BuTang
 * @Create 2023/12/27 9:51
 * @Version 1.0
 */
@Slf4j
@Component
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable cause) {
        return new UserClient() {
            @Override
            public User findById(Long id) {
                log.error("--------------------------查询用户异常");
                return new User();
            }
        };
    }
}
